<template>
  <div class="monthTable">
    <div class="monthTable_search1">
      <!-- v-if="roleName.indexOf('财政')!==-1" -->
      <span style="width:300px;display:inline-block">
        <span>单位:</span>
        <span>
          <el-select
            v-model="chooseEnterPriseValue"
            style="width:80%"
            size="small"
            placeholder="请选择单位"
            @focus="getAllEnterprise"
          >
            <el-option
              v-for="item in chooseEnterPriseOptions"
              :key="item.enterpriseGuid"
              :label="item.label"
              :value="item.label"
            />
          </el-select>
        </span>
      </span>
      <span>
        <span>报表时间:</span>
        <span style="width:150px;display:inline-block" class="datePicker">
          <el-date-picker
            v-model="datePicker"
            size="small"
            type="month"
            style="width:100%"
            value-format="yyyy-MM"
            placeholder="请选择日期"
            popper-class="date-style"
            @change="changePickerYear"
          />
        </span>
      </span>
      <span style="margin-left:30px">
        <el-button class="specialButton" size="small" @click="changeDate">查看</el-button>
        <el-button class="specialButton" size="small" @click="downFile">下载</el-button>
      </span>
    </div>
    <div class="monthTable_title">
      <span>{{ title }}</span>
      <span class="monthTable_title_status">
        <span>
          <img
            v-if="setId===1"
            style="width: 60px;vertical-align: middle;"
            src="@/assets/images/monthReport/noUpload.png"
          >
          <img
            v-if="setId===2"
            style="width: 60px;vertical-align: middle;"
            src="@/assets/images/monthReport/waiting.png"
          >
          <img
            v-if="setId===3"
            style="width: 60px;vertical-align: middle;"
            src="@/assets/images/monthReport/back.png"
          >
          <img
            v-if="setId===4"
            style="width: 60px;vertical-align: middle;"
            src="@/assets/images/monthReport/agree.png"
          >
        </span>
        <el-popover
          v-if="setId===3 && roleName.indexOf(&quot;乡镇&quot;)!==-1"
          placement="bottom"
          width="350"
          trigger="click"
        >
          <div style="padding:2px">
            <p class="backTitle">{{ title }}驳回原因</p>
            <div style="text-align: right; margin: 0">
              <el-input
                v-model="backReason"
                style="margin-top:10px"
                type="textarea"
                :rows="7"
                :disabled="true"
                placeholder="驳回理由"
              />
            </div>
            <div class="backTime">驳回时间:{{ backTime }}</div>
          </div>
          <el-button slot="reference" class="backButtonStyle">查看驳回原因</el-button>
        </el-popover>
      </span>
    </div>
    <div class="monthTable_search">
      <div style="flex:1">
        <vxe-input v-model="filterName" type="search" placeholder="试试全表搜索" @keyup="searchEvent" />
      </div>
      <div style="flex:1;text-align:right">
        <span v-if="roleName.indexOf('乡镇')!==-1">
          <span v-if="setId===1 || setId===3 ">
            <el-button :loading="submitLoading" size="small" type="primary" @click="submitReport">上报报表</el-button>
            <el-button
              :loading="buttonLoading"
              type="danger"
              size="small"
              @click="changeEdit"
            >{{ showEdit?"保存":"编辑" }}</el-button>
          </span>
        </span>
        <span v-else>
          <span v-if="setId===2">
            <el-button :loading="buttonLoading" type="danger" size="small" @click="backReport">驳回</el-button>
            <el-button size="small" type="primary" @click="agreeReport">通过</el-button>
          </span>
        </span>
      </div>
    </div>
    <div class="monthTable_table">
      <vxe-table
        ref="xTable"
        v-loading="tableLoading"
        :data="tableData"
        border
        resizable
        highlight-hover-row
        highlight-current-row
        :tree-config="{accordion: true,children: 'children', iconOpen: 'iconfont icon-xiajiantou', iconClose: 'iconfont icon-youjiantou'}"

        show-overflow
        :height="tableHeight"
        show-footer
        :footer-method="footerMethod"
        :cell-style="cellStyle"
        :header-cell-style="headerCellStyle"
        :footer-cell-class-name="footerCellClassName"
      >
        <vxe-table-column
          :min-width="100"
          width="180"
          field="copyFunctionCode"
          fixed="left"
          title="科目编码"
          tree-node
          type="html"
        />
        <vxe-table-column
          fixed="left"
          type="html"
          :min-width="300"
          :field="functionName"
          title="项目名称"
        />
        <vxe-table-column :min-width="120" :field="money1" title="原始金额(元)">
          <template slot-scope="scope">
            <div style="text-align:right">{{ scope.row[money1] }}</div>
          </template>
        </vxe-table-column>
        <vxe-table-column :min-width="120" :field="money2" title="金额(元)">
          <template slot-scope="scope">
            <div v-if="showEdit">
              <div v-if="scope.row.children">
                <el-input
                  v-if="scope.row.children.length!==0"
                  v-model="scope.row[money2]"
                  :disabled="true"
                />
                <el-input
                  v-else
                  v-model="scope.row[money2]"
                  @input="handleClick(scope.row)"
                />
              </div>
              <!-- @input="handleClick(scope.$index,scope.row)" -->
              <el-input
                v-if="!scope.row.children"
                v-model="scope.row[money2]"
                type="number"
                clearable
                @focus="focusInput(scope.row)"
                @input="handleClick(scope.row)"
              />
            </div>
            <div v-if="!showEdit" style="text-align:right">{{ scope.row[money2] }}</div>
          </template>
        </vxe-table-column>
        <vxe-table-column v-if="roleName.indexOf('财政')===-1" :min-width="60" title="操作" field="do">
          <template slot-scope="scope">
            <div style="text-align:center">
              <el-popover v-if="!scope.row.children" placement="right" width="450" trigger="click">
                <div class="changeContent">
                  <div class="changeContentTitle">金额修改记录:</div>
                  <div v-if="historyRecord.length!==0" class="changeContainer">
                    <div
                      v-for="(item,index) in historyRecord"
                      :key="index"
                      class="changeContent_item"
                    >
                      {{ index+1 }}.
                      <span v-html="item.CHANGE_CONTENT" />
                    </div>
                  </div>
                  <div v-else style="text-align:center">
                    <span style="color: red;">
                      <img
                        style="height:120px"
                        src="../../../../assets/images/monthReport/noReport.png"
                      >
                      <div>暂无修改记录</div>
                    </span>
                  </div>
                </div>
                <el-button
                  slot="reference"
                  style="padding: 5px 15px;"
                  type="small"
                  @click="showlog(scope.row)"
                >查看记录</el-button>
              </el-popover>
            </div>
          </template>
        </vxe-table-column>

        <template #empty>
          <span style="color: red;">
            <img style="height:150px" src="../../../../assets/images/monthReport/noReport.png">
            <div>暂无报表数据</div>
          </span>
        </template>
      </vxe-table>
    </div>
    <el-dialog
      v-dialogDrag
      :close-on-click-modal="false"
      :visible.sync="dialogVisible"
      width="600px"
      append-to-body
    >
      <div>
        <div v-html="backDialogTitle" />
        <el-input
          v-model="backReason"
          style="margin-top:10px"
          type="textarea"
          :rows="6"
          placeholder="请输入驳回理由"
        />
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button :loading="makeSureLoading" type="primary" @click="makeSureBack">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import XEUtils from 'xe-utils';
import {
  getHeader,
  getData,
  batchAudit,
  showStatus,
  uploadTables,
  showPubLog,
  exportExcel
} from '@/api/monthReport/index.js';
// import { showEnterprise } from '@/api/sysConfig/index';
import { getCurrentTime, downloadFile } from '@/utils/commonMethods.js';
import { Message } from 'element-ui';
export default {
  data() {
    return {
      originTableData: [],
      filterName: '',
      tableHeight: '',
      title: '',
      tableData: [],
      tableLoading: false,
      showEdit: false,
      datePicker: localStorage.getItem('chooseYear') + '-' + (new Date().getMonth() + 1),
      content: '',
      buttonLoading: false,
      chooseEnterPriseValue: '',
      chooseEnterPriseOptions: [],
      roleName: localStorage.getItem('xcRoleName'),
      historyRecord: [],
      reportStatus: '',
      setId: '',
      reportType: '',
      iVouchId: '',
      backDialogTitle: '',
      dialogVisible: false,
      backReason: '',
      functionName: '',
      money1: '',
      money2: '',
      columnList: '',
      headerList: '',
      backTime: '',
      submitLoading: false,
      makeSureLoading: false

    };
  },
  mounted() {
    this.tableHeight =
      window.innerHeight - this.$refs.xTable.$el.offsetTop - 160;
  },
  created() {
    this.title = localStorage.getItem('siderName');
    // 月报
    if (localStorage.getItem('siderName') === '一般公共预算分类支出月报') {
      this.reportType = '2';
      this.iVouchId = '8281';
      this.functionName = 'CNAME';
      this.money1 = 'IMONEY';
      this.money2 = 'ITMONEY2';
    }
    // 公共
    if (localStorage.getItem('siderName') === '一般公共预算支出表') {
      this.iVouchId = '8261';
      this.reportType = '1';
      this.functionName = 'CFUNCTIONNAME';
      this.money1 = 'ITMONEY1';
      this.money2 = 'ITMONEY2';
    }
    const a = JSON.parse(localStorage.getItem('enterprise_jc'));
    if (a.length === 1 && localStorage.getItem('xcRoleName').indexOf('乡镇') !== -1) {
      this.chooseEnterPriseValue = a[0].ISBN_CODE + ' ' + a[0].NAME;
    }
  },
  methods: {
    changePickerYear() {
      if (this.datePicker) {
        this.datePicker = localStorage.getItem('chooseYear') + '-' + this.datePicker.split('-')[1];
      }
    },
    // 下载文件
    downFile() {
      if (this.originTableData.length === 0) {
        Message({
          message: '暂无数据,无法下载',
          type: 'warning'
        });
      } else {
        const enterpriseCode = this.chooseEnterPriseValue.split(' ')[0];
        const enterpriseName = this.chooseEnterPriseValue.split(' ')[1];
        exportExcel({
          columnList: this.columnList,
          headerList: this.headerList,
          moneyType: '1',
          year: this.datePicker.split('-')[0],
          month: this.datePicker.split('-')[1],
          orderBy: '',
          pageType: '0',
          filterList: [
            {
              value: `${enterpriseName}`,
              col: 'ENTERPRISE_NAME',
              symbol: 'eq'
            },
            {
              value: `${enterpriseCode}`,
              col: 'ENTERPRISE_CODE',
              symbol: 'eq'
            },
            {
              value: `1`,
              col: 'REPORT_TYPE',
              symbol: 'eq'
            }
          ]
        }).then(res => {
          downloadFile(res, `${localStorage.getItem('siderName')}.xls`, '.xls');
        });
      }
    },
    // 驳回报表
    backReport() {
      this.backReason = '';
      this.backDialogTitle = `是否<span style='color:red'>驳回</span>${
        this.chooseEnterPriseValue.split(' ')[1]
      }${localStorage.getItem('siderName')}？`;
      this.dialogVisible = true;
    },
    makeSureBack() {
      this.makeSureLoading = true;
      uploadTables({
        setId: '3',
        year: this.datePicker.split('-')[0],
        month: this.datePicker.split('-')[1],
        enterpriseCode: this.chooseEnterPriseValue.split(' ')[0],
        enterpriseName: this.chooseEnterPriseValue.split(' ')[1],
        reportType: this.reportType,
        reviewer: localStorage.getItem('xcUserId'),
        reasons: this.backReason
      }).then(res => {
        this.makeSureLoading = false;
        if (res.success) {
          Message({
            type: 'success',
            message: '驳回成功!'
          });
          this.dialogVisible = false;
          showStatus({
            year: this.datePicker.split('-')[0],
            month: this.datePicker.split('-')[1],
            enterpriseCode: this.chooseEnterPriseValue.split(' ')[0],
            enterpriseName: this.chooseEnterPriseValue.split(' ')[1],
            reportType: this.reportType
          }).then(res => {
            if (res.success) {
              this.setId = res.data.setId;
            } else {
              this.setId = 1;
            }
          });
          this.getData();
          setTimeout(() => {
            this.searchEvent();
          }, 500);
        } else {
          Message({
            type: 'warning',
            message: '驳回失败,请联系管理员'
          });
        }
      });
    },
    // 获取单位
    getAllEnterprise() {
      // if (this.roleName.indexOf('财政') === -1) {
      const a = JSON.parse(localStorage.getItem('enterprise_jc'));
      a.map(o => {
        o.enterpriseGuid = o.ENTERPRISE_GUID;
        o.label = o.ISBN_CODE + ' ' + o.NAME;
      });
      this.chooseEnterPriseOptions = a;
      // }
      // else {
      //   showEnterprise({
      //     userId: ''
      //   }).then(res => {
      //     if (res.success) {
      //       this.chooseEnterPriseOptions = res.data;
      //     } else {
      //       this.chooseEnterPriseOptions = [];
      //     }
      //   });
      // }
    },
    // 查看详情
    showlog(row) {
      showPubLog({
        year: this.datePicker.split('-')[0],
        month: this.datePicker.split('-')[1],
        enterpriseCode: this.chooseEnterPriseValue.split(' ')[0],
        enterpriseName: this.chooseEnterPriseValue.split(' ')[1],
        reportType: this.reportType,
        code: row.copyFunctionCode
      }).then(res => {
        if (res.success) {
          this.historyRecord = res.data;
        } else {
          this.historyRecord = [];
        }
      });
    },
    changeDate() {
      if (this.roleName.indexOf('财政') !== -1) {
        if (this.chooseEnterPriseValue === '') {
          Message({
            type: 'warning',
            message: '单位不能为空!'
          });
        } else if (!this.datePicker) {
          Message({
            type: 'warning',
            message: '日期不能为空!'
          });
        } else {
          showStatus({
            year: this.datePicker.split('-')[0],
            month: this.datePicker.split('-')[1],
            enterpriseCode: this.chooseEnterPriseValue.split(' ')[0],
            enterpriseName: this.chooseEnterPriseValue.split(' ')[1],
            reportType: this.reportType
          }).then(res => {
            if (res.success) {
              this.setId = res.data.setId;
              if (res.data.setId !== 1) {
                this.getData();
                setTimeout(() => {
                  this.searchEvent();
                }, 500);
              } else {
                this.tableData = [];
                this.originTableData = [];
                this.tableLoading = true;
                setTimeout(() => {
                  this.tableLoading = false;
                }, 1000);
              }
            } else {
              this.setId = 1;
            }
          });
        }
      } else {
        if (!this.datePicker) {
          Message({
            type: 'warning',
            message: '日期不能为空!'
          });
        } else if (this.chooseEnterPriseValue === '') {
          Message({
            type: 'warning',
            message: '单位不能为空!'
          });
        } else {
          this.getData();
          setTimeout(() => {
            this.searchEvent();
          }, 500);
        }
      }
    },
    // 输入框聚焦的时候
    focusInput(row) {
      if (row.count === 0) {
        row.originMoney = row[this.money2] !== '' ? row[this.money2] : 0;
      }
      row.count++;
    },
    footerMethod({ columns, data }) {
      const footerData = [
        columns.map((column, columnIndex) => {
          if (columnIndex === 0) {
            return '合计';
          } else {
            if (
              column.property === this.functionName ||
              column.property === 'do'
            ) {
              return '--';
            } else {
              return XEUtils.sum(data, column.property);
            }
          }
        })
      ];
      this.sumList = footerData[0];
      return footerData;
    },
    headerCellStyle({ column, columnIndex }) {
      if (column.property === this.money1 || column.property === this.money2) {
        return {
          textAlign: 'right',
          backgroundColor: 'rgb(64, 158, 255)',
          color: '#fff',
          borderBottom: '1px solid #fff'
        };
      } else if (column.property === 'do') {
        return {
          textAlign: 'center',
          backgroundColor: 'rgb(64, 158, 255)',
          color: '#fff',
          borderBottom: '1px solid #fff'
        };
      } else {
        return {
          backgroundColor: 'rgb(64, 158, 255)',
          color: '#fff',
          borderBottom: '1px solid #fff'
        };
      }
    },
    footerCellClassName({ $rowIndex, columnIndex }) {
      if (columnIndex === 2 || columnIndex === 3) {
        return 'footer-col-right';
      }
    },
    cellStyle({ row, rowIndex, column }) {
      if (column.property === this.functionName) {
        return {
          textAlign: 'left'

        };
      }
      if (column.property === 'copyFunctionCode' && row.children) {
        return {
          fontWeight: 'bolder'
        };
      }
    },
    submitReport() {
      this.$confirm('此操作将上传报表, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        if (this.originTableData.length === 0) {
          Message({
            type: 'warning',
            message: '暂无数据,无法上传!'
          });
        } else {
          this.submitLoading = true;
          // 先调用保存接口,为了防止空数据进入
          this.updateDataSource('isCz');
          setTimeout(() => {
            uploadTables({
              setId: '2',
              year: this.datePicker.split('-')[0],
              month: this.datePicker.split('-')[1],
              enterpriseCode: this.chooseEnterPriseValue.split(' ')[0],
              enterpriseName: this.chooseEnterPriseValue.split(' ')[1],
              reportType: this.reportType
            }).then(res => {
              this.submitLoading = false;
              if (res.success) {
                Message({
                  type: 'success',
                  message: '上报成功!'
                });
                this.getData();
                setTimeout(() => {
                  this.searchEvent();
                }, 500);
              } else {
                Message({
                  type: 'warning',
                  message: '上报失败,请联系管理员'
                });
              }
            });
          }, 500);
        }
      });
    },
    handleClick(e1) {
      if (e1[this.money2].length >= 14) {
        Message({
          type: 'warning',
          message: '填写数字太大，请重新填写'
        });
        e1[this.money2] = '';
      } else {
        const q = e1.CFUNCTIONCODE;
        const a = this.tableData.filter(o => {
          if (q.substring(0, 3) === o.CFUNCTIONCODE) {
            return o;
          }
        });
        if (a[0].children.length !== 0) {
          if (q.length > 6) {
            const b = a[0].children.filter(o => {
              if (q.substring(0, 5) === o.CFUNCTIONCODE) {
                return o;
              }
            });
            let subSum = 0;
            b[0].children.map(o => {
              if (o[this.money2] != null) {
                subSum += Number(o[this.money2]);
              }
            });
            b[0][this.money2] = subSum.toFixed(2);
            let sum = 0;
            a[0].children.map(o => {
              if (o[this.money2] != null) {
                sum += Number(o[this.money2]);
              }
            });
            a[0][this.money2] = sum.toFixed(2);
          } else {
            let sum = 0;
            a[0].children.map(o => {
              if (o[this.money2] != null) {
                sum += Number(o[this.money2]);
              }
            });
            a[0][this.money2] = sum.toFixed(2);
          }
        }
        setTimeout(() => {
          this.content = '';
          const xcNickName = localStorage.getItem('xcNickName');
          // 自己拼接修改的内容 时间+用户+ 调整金额+ 原先金额
          this.content =
          getCurrentTime() +
          '【<span style="color:#1890ff">' +
          xcNickName +
          '</span>】' +
          '调整金额【<span style="color:#1890ff">' +
          e1[this.money2] +
          '</span>】元';
          e1.changeContent = '';
          e1.changeContent = this.content;
        }, 200);
        setTimeout(() => {
          this.originTableData.map((item, index) => {
            if (q.substring(0, 3) === item.CFUNCTIONCODE) {
              this.originTableData[index] = a[0];
            }
          });
          // 实时更新
          this.$refs.xTable.updateFooter();
        }, 500);
      }
    },
    changeEdit() {
      // 保存的时候
      if (this.tableData.length === 0) {
        Message({
          message: '暂无数据,无法编辑',
          type: 'warning'
        });
      } else {
        setTimeout(() => {
          if (this.showEdit) {
            this.buttonLoading = true;
            this.updateDataSource('editor');
          } else {
            this.showEdit = !this.showEdit;
          }
        }, 500);
      }
    },
    updateDataSource(type) {
      batchAudit({
        list: this.originTableData,
        year: this.datePicker.split('-')[0],
        month: this.datePicker.split('-')[1],
        enterpriseCode: this.chooseEnterPriseValue.split(' ')[0],
        enterpriseName: this.chooseEnterPriseValue.split(' ')[1],
        reportType: this.reportType
      }).then(res => {
        if (res.success) {
          if (type === 'editor') {
            Message({
              message: '保存数据成功',
              type: 'success'
            });
            this.showEdit = !this.showEdit;
          } else {
            this.showEdit = false;
          }

          XEUtils.eachTree(
            this.tableData,
            item => {
              item.count = 0;
              item.changeContent = '';
            },
            []
          );
          XEUtils.eachTree(
            this.originTableData,
            item => {
              item.count = 0;
              item.changeContent = '';
            },
            []
          );
        } else {
          Message({
            message: '保存数据失败',
            type: 'warning'
          });
        }

        // this.getData();
        // setTimeout(() => {
        //   this.searchEvent();
        // }, 300);
        setTimeout(() => {
          this.buttonLoading = false;
        }, 500);
      });
    },

    getData() {
      this.tableLoading = true;
      getHeader({
        iVouchId: this.iVouchId
      }).then(res => {
        if (res.success) {
          this.columnList = res.data.columnList;
          this.headerList = res.data.headerList;
          const enterpriseCode = this.chooseEnterPriseValue.split(' ')[0];
          const enterpriseName = this.chooseEnterPriseValue.split(' ')[1];

          getData({
            columnList: res.data.columnList,
            headerList: res.data.headerList,
            moneyType: '1',
            year: this.datePicker.split('-')[0],
            month: this.datePicker.split('-')[1],
            orderBy: '',
            pageType: '0',
            filterList: [
              {
                value: `${enterpriseName}`,
                col: 'ENTERPRISE_NAME',
                symbol: 'eq'
              },
              {
                value: `${enterpriseCode}`,
                col: 'ENTERPRISE_CODE',
                symbol: 'eq'
              },
              {
                value: `${this.reportType}`,
                col: 'REPORT_TYPE',
                symbol: 'eq'
              }
            ]
          }).then(res => {
            this.tableLoading = false;
            if (res.success) {
              if (res.data === '') {
                this.originTableData = [];
              } else {
                this.originTableData = res.data;
              }
            } else {
              this.originTableData = [];
            }
          });
        }
      });
    },

    searchEvent() {
      // 去前后空格 大小写 字符串
      const filterName = (this.filterName + '').trim().toLowerCase();
      if (filterName) {
        const filterRE = new RegExp(filterName, 'gi');
        const options = { children: 'children' };
        const searchProps = ['copyFunctionCode', this.functionName];
        const rest = XEUtils.searchTree(
          this.originTableData,
          item =>
            searchProps.some(
              key => (item[key] + '').toLowerCase().indexOf(filterName) > -1
            ),
          options
        );
        XEUtils.eachTree(
          rest,
          item => {
            item.copyFunctionCode = item.CFUNCTIONCODE;
            searchProps.forEach(key => {
              item[key] = (item[key] + '').replace(
                filterRE,
                match => `<span class="keyword-lighten">${match}</span>`
              );
            });
          },
          options
        );
        this.tableData = rest;
        // 搜索之后默认展开所有子节点
        this.$nextTick(() => {
          this.$refs.xTable.setAllTreeExpand(true);
        });
      } else {
        this.tableData = this.originTableData;
        XEUtils.eachTree(
          this.tableData,
          item => {
            item.copyFunctionCode = item.CFUNCTIONCODE;
            if (
              localStorage.getItem('siderName') === '一般公共预算分类支出月报'
            ) {
              item.IMONEY = item.IMONEY + '';
              if (item.ITMONEY2 !== '') {
                item.ITMONEY2 = item.ITMONEY2 + '';
              } else {
                item.ITMONEY2 = item.IMONEY + '';
              }
            } else {
              item.ITMONEY1 = item.ITMONEY1 + '';
              if (item.ITMONEY2 !== '') {
                item.ITMONEY2 = item.ITMONEY2 + '';
              } else {
                item.ITMONEY2 = item.ITMONEY1 + '';
              }
            }
            item.count = 0;
            // item.changeContent === '' ? item.changeContent = {} : item.changeContent;
          },
          []
        );
      }
      // if (this.roleName.indexOf('乡镇') !== -1) {
      this.getReportStatus();
      // }
    },
    agreeReport() {
      this.$confirm('此操作将通过报表, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        if (this.originTableData.length === 0) {
          Message({
            type: 'warning',
            message: '暂无数据,无法通过!'
          });
        } else {
          uploadTables({
            setId: '4',
            year: this.datePicker.split('-')[0],
            month: this.datePicker.split('-')[1],
            enterpriseCode: this.chooseEnterPriseValue.split(' ')[0],
            enterpriseName: this.chooseEnterPriseValue.split(' ')[1],
            reportType: this.reportType
          }).then(res => {
            if (res.success) {
              Message({
                type: 'success',
                message: '通过成功!'
              });
              this.getData();
              setTimeout(() => {
                this.searchEvent();
              }, 500);
            } else {
              Message({
                type: 'warning',
                message: '通过失败,请联系管理员'
              });
            }
          });
        }
      });
    },
    // 获取报表的状态
    getReportStatus() {
      showStatus({
        year: this.datePicker.split('-')[0],
        month: this.datePicker.split('-')[1],
        enterpriseCode: this.chooseEnterPriseValue.split(' ')[0],
        enterpriseName: this.chooseEnterPriseValue.split(' ')[1],
        reportType: this.reportType
      }).then(res => {
        if (res.success) {
          this.setId = res.data.setId;
          this.backReason = res.data.reasons;
          this.backTime = res.data.reviewerTime;
          //  1 未上报  2等待审核   3 已驳回 4 已通过（已上报）
        } else {
          this.setId = 1;
        }
      });
    }
  }
};
</script>

<style lang='scss' scoped>
.monthTable_search1 {
  padding: 2px 15px;
}
.monthTable_title {
  height: 40px;
  opacity: 1;
  font-size: 25px;
  font-family: PingFangSC, PingFangSC-Medium;
  font-weight: 500;
  text-align: center;
  color: rgba(0, 0, 0, 0.85);
  line-height: 40px;
  margin-top: 5px;
}
.monthTable_search {
  margin-bottom: 5px;
  display: flex;
  padding: 0px 10px;
}
.keyword-lighten {
  color: #000;
  background-color: #ffff00;
}
.monthTable_table .vxe-body--row.row-green {
  background-color: #187;
  color: #fff;
}

.monthTable_table
  /deep/
  .vxe-table
  .vxe-body--column.col--ellipsis
  > .vxe-cell
  .vxe-tree-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left !important;
}
.monthTable_table /deep/ .vxe-table .vxe-body--column.col--ellipsis,
.vxe-table.vxe-editable .vxe-body--column,
.vxe-table .vxe-footer--column.col--ellipsis,
.vxe-table .vxe-header--column.col--ellipsis {
  height: 35px !important;
}
.monthTable_table /deep/ .el-input__inner {
  height: 30px !important;
  line-height: 30px !important;
}
.monthTable_table /deep/ .vxe-table--footer-wrapper.body--wrapper {
  overflow-x: auto;
  background: #c0ebff !important;
  font-size: 16px;
}
.specialButton {
  background: #ffffff;
  border: 1px solid #1890ff;
  border-radius: 3px;
  color: #1890ff;
}
.changeContentTitle {
  opacity: 1;
  font-size: 14px;
  font-family: PingFangSC, PingFangSC-Medium;
  font-weight: 500;
  text-align: left;
  color: rgba(0, 0, 0, 0.85);
  line-height: 22px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.3);
  padding: 5px 10px;
}
.changeContainer {
  padding: 5px;
  height: 250px;
  overflow-y: auto;
}
.changeContent_item {
  opacity: 1;
  font-size: 14px;
  font-family: PingFangSC, PingFangSC-Medium;
  font-weight: 500;
  text-align: left;
  line-height: 32px;
  margin: 5px 0px;
}

.changeContent_item:nth-child(2n) {
  background: #e6f7ff;
}
.backStyle {
  width: 84px;
  height: 20px;
  opacity: 1;
  font-size: 14px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight: 400;
  text-align: left;
  color: #1890ff;
  line-height: 20px;
}
.backButtonStyle {
  width: 100px;
  border: none;
  padding: 0px;
  font-size: 14px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight: 400;
  text-align: left;
  color: #1890ff;
  line-height: 20px;
}
.backButtonStyle:hover {
  background: #fff;
  text-decoration: underline;
}
.backButtonStyle:focus {
  background: #fff;
}
.backTitle {
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
  height: 30px;
  line-height: 30px;
  font-size: 15px;
  font-weight: bolder;
}
.backTime {
  opacity: 1;
  font-size: 12px;
  font-family: PingFangSC, PingFangSC-Medium;
  font-weight: 500;
  text-align: left;
  color: rgba(0, 0, 0, 0.25);
  line-height: 17px;
  text-align: right;
  margin-top: 10px;
}
</style>
